package com.gtxc.kotlinmvvm.adapater;

import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gtxc.kotlinmvvm.R;
import com.gtxc.kotlinmvvm.network.request.TitlBeanItem;

import org.jetbrains.annotations.NotNull;

/**
 * FileName:NewsConsultingAdapater
 * Author：Administrator
 * Date:2021 2021/9/28 21:12
 * Copyright (C), 2020-2021,成都拇音科技有限公司
 * <p>
 * <p>
 * Description: zwl
 * History:
 * <author> <time> <version> <desc>
 * 作者姓名 修改时间 版本号 描述
 */
public class NewsConsultingAdapater extends BaseQuickAdapter<TitlBeanItem,BaseViewHolder> {
    public NewsConsultingAdapater(int layoutResId) {
        super(layoutResId);

    }
    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, TitlBeanItem o) {

        if (baseViewHolder.getPosition()==0){
            baseViewHolder.setBackgroundResource(R.id.iv_01,R.mipmap.xinweinitma);
        }else if (baseViewHolder.getPosition()==1){
            baseViewHolder.setBackgroundResource(R.id.iv_01,R.mipmap.xinweinitmb);
        }else if (baseViewHolder.getPosition()==2){
            baseViewHolder.setBackgroundResource(R.id.iv_01,R.mipmap.xinweinitmc);
        }else {
//view要设置margin的view
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
            lp.setMargins(60, 0, 0, 0);
//view要设置margin的view
            baseViewHolder.findView(R.id.iv_01).setLayoutParams(lp);

        }
        baseViewHolder.setText(R.id.iv_01,(baseViewHolder.getPosition()+1)+"");
        baseViewHolder.setText(R.id.tv_02,o.getTitle());
    }



    @Override
    public int getItemViewType(int position) {
        return position;
    }
}
